package com.sdgs.paas.sdk.core.metrics;
//package com.shtel.paas.sdk.core.metrics;
//
//import java.io.IOException;
//import java.lang.reflect.ParameterizedType;
//import java.lang.reflect.Type;
//import java.utils.List;
//
//import org.springframework.core.MethodParameter;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.http.server.ServletServerHttpRequest;
//import org.springframework.utils.Assert;
//import org.springframework.web.HttpMediaTypeNotSupportedException;
//import org.springframework.web.bind.support.WebDataBinderFactory;
//import org.springframework.web.context.request.NativeWebRequest;
//import org.springframework.web.method.support.ModelAndViewContainer;
//import org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor;
//
//import com.shtel.paas.sdk.core.IPaasParam;
//import com.shtel.paas.sdk.core.PaasBaseRequest;
//
//public class PaasMethodProcessor extends HttpEntityMethodProcessor {
//
//	public PaasMethodProcessor(List<HttpMessageConverter<?>> converters) {
//		super(converters);
//	}
//
//	@Override
//	public boolean supportsParameter(MethodParameter parameter) {
//
//		return PaasBaseRequest.class == parameter.getParameterType();
//	}
//
//	@Override
//	public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
//			NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
//			throws IOException, HttpMediaTypeNotSupportedException {
//		ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
//		Type paramType = getHttpEntityType(parameter);
//		if (paramType == null) {
//			throw new IllegalArgumentException("HttpEntity parameter '" + parameter.getParameterName() + "' in method "
//					+ parameter.getMethod() + " is not parameterized");
//		}
//
//		Object body = readWithMessageConverters(webRequest, parameter, paramType);
//
//		return new PaasBaseRequest<Object>(body);
//
//	}
//
//	private Type getHttpEntityType(MethodParameter parameter) {
//		Assert.isAssignable(HttpEntity.class, parameter.getParameterType());
//		Type parameterType = parameter.getGenericParameterType();
//		if (parameterType instanceof ParameterizedType) {
//			ParameterizedType type = (ParameterizedType) parameterType;
//			if (type.getActualTypeArguments().length != 1) {
//				throw new IllegalArgumentException("Expected single generic parameter on '"
//						+ parameter.getParameterName() + "' in method " + parameter.getMethod());
//			}
//			return type.getActualTypeArguments()[0];
//		} else if (parameterType instanceof Class) {
//			return Object.class;
//		} else {
//			return null;
//		}
//	}
//
//}